<!doctype html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .container{
            width:100%;
            overflow:hidden;
            box-sizing:border-box;
            background:#000;
          }
    </style>
</head>
<body>
<div class="container">

</div>
<script type="text/javascript">
    var h5Port;
    window.addEventListener('message', function (event) {
        if (event.data === '__init_port__') {
            if (event.ports[0] !== null) {
                h5Port = event.ports[0]; // 1. 保存从应用侧发送过来的端口。
                h5Port.onmessage = function (event) {
                   initData()
                }
            }
        }
    })
    function initData() {
        console.log('initData')
        let richtext = RichText.getContent()
        document.querySelector('.container').innerHTML = richtext
    }
    initData()
</script>
</body>
</html>